#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct
{
    char name[25],sir,west;
	int scoa,scob,paper;
	int money;//int money=0瑞格不通过 
}stu;
int main()
{
   int n,i,num,maxmoney,maxi;
   stu *p;
   while((scanf("%d",&n))!=EOF)
   {
   	  num=0;
   	  maxmoney=0;
   	  p=(stu *)calloc(n,sizeof(stu));
   	  for(i=0;i<n;i++)
   	  {
   	  	(p+i)->money=0;//瑞格只能这样初始化才能通过 
   	  	scanf("%s %d %d %c %c %d",(p+i)->name,&(p+i)->scoa,&(p+i)->scob,&(p+i)->sir,&(p+i)->west,&(p+i)->paper);
   	    if((p+i)->scoa>80&&(p+i)->paper>=1)
   	    (p+i)->money=(p+i)->money+8000;
   	    
   	    if((p+i)->scoa>85&&(p+i)->scob>80)
   	    (p+i)->money=(p+i)->money+4000;
   	    
   	    if((p+i)->scoa>90)
   	    (p+i)->money=(p+i)->money+2000;
   	    
   	    if((p+i)->scoa>85&&(p+i)->west=='Y')
   	    (p+i)->money=(p+i)->money+1000;
   	    
   	    if((p+i)->scob>80&&(p+i)->sir=='Y')
   	    (p+i)->money=(p+i)->money+850;
   	    
   	    if((p+i)->money>maxmoney)
   	    {
   	    	maxmoney=(p+i)->money;
   	    	maxi=i;
		}
		num=num+(p+i)->money;
	  }
	  printf("%s\n",(p+maxi)->name);
	  printf("%d\n",(p+maxi)->money);
	  printf("%d\n",num);
      free(p);
   }
   return 0;      
}